package com.zhuss.core.processor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.vo.core.user.DetailUserVo;
import com.zhuss.enums.StartStopEnum;
import com.zhuss.exception.AabException;


@Component("userCheck")
public class UserCheck {
	
	@Autowired
	@Qualifier("userRead")
	private UserRead userRead;

	
	public boolean checkStart(Long userId) throws AabException {
		DetailUserVo user = ((DetailUserVo) userRead.detail(userId));
		if (StartStopEnum.停用.sameKey(user.getStatus())) {
			return true;
		}
		return false;
	}
	
	public boolean checkStop(Long userId) throws AabException {
		DetailUserVo user = ((DetailUserVo) userRead.detail(userId));
		if (StartStopEnum.启用.sameKey(user.getStatus())) {
			return true;
		}
		return false;
	}
	
	public boolean checkBind(Long userId) throws AabException {
		DetailUserVo user = ((DetailUserVo) userRead.detail(userId));
		if (user.getOpenId() == null || "".equals(user.getOpenId().trim())) {
			return false;
		}
		return true;
	}
	
	public boolean checkUnbind(Long userId) throws AabException {
		DetailUserVo user = ((DetailUserVo) userRead.detail(userId));
		if (user.getOpenId() != null || !"".equals(user.getOpenId().trim())) {
			return false;
		}
		return true;
	}

}
